package com.dynamixsoftware.printershare.smb;

import com.dynamixsoftware.printershare.smb.util.Dumper;
import java.io.UnsupportedEncodingException;
import java.util.Date;

class SmbComNegotiateResponse
  extends ServerMessageBlock
{
  int dialectIndex;
  private SmbTransport.ServerData server;
  
  SmbComNegotiateResponse(SmbTransport.ServerData paramServerData)
  {
    this.server = paramServerData;
  }
  
  int readBytesWireFormat(byte[] paramArrayOfByte, int paramInt)
  {
    int i = paramInt;
    int j;
    if ((0x80000000 & this.server.capabilities) == 0)
    {
      this.server.encryptionKey = new byte[this.server.encryptionKeyLength];
      System.arraycopy(paramArrayOfByte, paramInt, this.server.encryptionKey, 0, this.server.encryptionKeyLength);
      paramInt += this.server.encryptionKeyLength;
      if (this.byteCount > this.server.encryptionKeyLength) {
        j = 0;
      }
    }
    try
    {
      int k = 0x8000 & this.flags2;
      j = 0;
      if (k == 32768)
      {
        while ((paramArrayOfByte[(paramInt + j)] != 0) || (paramArrayOfByte[(1 + (paramInt + j))] != 0))
        {
          j += 2;
          if (j > 256) {
            throw new RuntimeException("zero termination not found");
          }
        }
        this.server.oemDomainName = new String(paramArrayOfByte, paramInt, j, "UTF-16LE");
      }
      else
      {
        while (paramArrayOfByte[(paramInt + j)] != 0)
        {
          j++;
          if (j > 256) {
            throw new RuntimeException("zero termination not found");
          }
        }
        this.server.oemDomainName = new String(paramArrayOfByte, paramInt, j, "ISO-8859-1");
      }
    }
    catch (UnsupportedEncodingException localUnsupportedEncodingException)
    {
      paramInt += j;
    }
    this.server.oemDomainName = new String();
    break label281;
    this.server.guid = new byte[16];
    System.arraycopy(paramArrayOfByte, paramInt, this.server.guid, 0, 16);
    this.server.oemDomainName = new String();
    label281:
    return paramInt - i;
  }
  
  int readParameterWordsWireFormat(byte[] paramArrayOfByte, int paramInt)
  {
    boolean bool1 = true;
    this.dialectIndex = readInt2(paramArrayOfByte, paramInt);
    int i = paramInt + 2;
    if (this.dialectIndex > 10) {
      return i - paramInt;
    }
    SmbTransport.ServerData localServerData1 = this.server;
    int j = i + 1;
    localServerData1.securityMode = (0xFF & paramArrayOfByte[i]);
    this.server.security = (0x1 & this.server.securityMode);
    SmbTransport.ServerData localServerData2 = this.server;
    boolean bool2;
    boolean bool3;
    label122:
    SmbTransport.ServerData localServerData4;
    if ((0x2 & this.server.securityMode) == 2)
    {
      bool2 = bool1;
      localServerData2.encryptedPasswords = bool2;
      SmbTransport.ServerData localServerData3 = this.server;
      if ((0x4 & this.server.securityMode) != 4) {
        break label345;
      }
      bool3 = bool1;
      localServerData3.signaturesEnabled = bool3;
      localServerData4 = this.server;
      if ((0x8 & this.server.securityMode) != 8) {
        break label351;
      }
    }
    for (;;)
    {
      localServerData4.signaturesRequired = bool1;
      this.server.maxMpxCount = readInt2(paramArrayOfByte, j);
      int k = j + 2;
      this.server.maxNumberVcs = readInt2(paramArrayOfByte, k);
      int m = k + 2;
      this.server.maxBufferSize = readInt4(paramArrayOfByte, m);
      int n = m + 4;
      this.server.maxRawSize = readInt4(paramArrayOfByte, n);
      int i1 = n + 4;
      this.server.sessionKey = readInt4(paramArrayOfByte, i1);
      int i2 = i1 + 4;
      this.server.capabilities = readInt4(paramArrayOfByte, i2);
      int i3 = i2 + 4;
      this.server.serverTime = readTime(paramArrayOfByte, i3);
      int i4 = i3 + 8;
      this.server.serverTimeZone = readInt2(paramArrayOfByte, i4);
      int i5 = i4 + 2;
      SmbTransport.ServerData localServerData5 = this.server;
      int i6 = i5 + 1;
      localServerData5.encryptionKeyLength = (0xFF & paramArrayOfByte[i5]);
      return i6 - paramInt;
      bool2 = false;
      break;
      label345:
      bool3 = false;
      break label122;
      label351:
      bool1 = false;
    }
  }
  
  public String toString()
  {
    StringBuilder localStringBuilder = new StringBuilder().append("SmbComNegotiateResponse[").append(super.toString()).append(",wordCount=").append(this.wordCount).append(",dialectIndex=").append(this.dialectIndex).append(",securityMode=0x").append(Dumper.toHexString(this.server.securityMode, 1)).append(",security=");
    if (this.server.security == 0) {}
    for (String str = "share";; str = "user") {
      return new String(str + ",encryptedPasswords=" + this.server.encryptedPasswords + ",maxMpxCount=" + this.server.maxMpxCount + ",maxNumberVcs=" + this.server.maxNumberVcs + ",maxBufferSize=" + this.server.maxBufferSize + ",maxRawSize=" + this.server.maxRawSize + ",sessionKey=0x" + Dumper.toHexString(this.server.sessionKey, 8) + ",capabilities=0x" + Dumper.toHexString(this.server.capabilities, 8) + ",serverTime=" + new Date(this.server.serverTime) + ",serverTimeZone=" + this.server.serverTimeZone + ",encryptionKeyLength=" + this.server.encryptionKeyLength + ",byteCount=" + this.byteCount + ",oemDomainName=" + this.server.oemDomainName + "]");
    }
  }
  
  int writeBytesWireFormat(byte[] paramArrayOfByte, int paramInt)
  {
    return 0;
  }
  
  int writeParameterWordsWireFormat(byte[] paramArrayOfByte, int paramInt)
  {
    return 0;
  }
}


/* Location:           C:\Users\Admin\Desktop\Decompiler\JAD\jd-gui-0.3.6.windows\classes_dex2jar.jar
 * Qualified Name:     com.dynamixsoftware.printershare.smb.SmbComNegotiateResponse
 * JD-Core Version:    0.7.0.1
 */